package com.txm.drawPic;
/*
* 随机数字  用于控制敌方坦克的方向和是否发射子弹
*
* */
import java.util.Arrays;

public class RandomNum extends Thread {
    int randomNum = 3;
    int[] randomNum_range;
    int sleepSeconds;

    public RandomNum(int[] randomNum_range, int sleepSeconds) {
        this.randomNum_range = randomNum_range;
        this.sleepSeconds = sleepSeconds;
    }

    public int getRandomNum() {
        return randomNum;
    }

    public void run() {
        while (true) {
            randomNum = (int) (Math.random() * (Arrays.stream(randomNum_range).max().getAsInt() - Arrays.stream(randomNum_range).min().getAsInt() + 1) + Arrays.stream(randomNum_range).min().getAsInt());
            try {
                Thread.sleep(sleepSeconds);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

